package jh.com.jhappbf.work;

import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import jh.com.jhappbf.R;

/**
 * @author : wwh
 * e-mail  : 953889276@qq.com
 * time    : 2019-6-22 15:36:07
 * desc    :
 */
public class WorkQueryMain extends Fragment implements OnClickListener {
    private RelativeLayout mQueryLayout;
    private RelativeLayout mSettingLayout;
    private ImageView mQueryImg;
    private ImageView mSettingImg;
    private String mStartTime = "";
    private String mStartDate = "";
    private String mEndTime = "";
    private String mEndDate = "";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View v = inflater.inflate(R.layout.work_query_main, null);
        initView(v);
        return v;
    }

    private void initView(View v) {
        mQueryImg = v.findViewById(R.id.work_main_query_img);
        mQueryLayout = v.findViewById(R.id.work_main_query_layout);
        mSettingImg = v.findViewById(R.id.work_main_setting_img);
        mSettingLayout = v.findViewById(R.id.work_main_setting_layout);
        mQueryLayout.setOnClickListener(this);
        mQueryImg.setOnClickListener(this);
        mSettingLayout.setOnClickListener(this);
        mSettingImg.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.work_main_query_img:
            case R.id.work_main_query_layout:
                Intent intent = new Intent(getContext(), WorkQueryActivity.class);
                intent.putExtra("startTime",mStartTime);
                intent.putExtra("startDate",mStartDate);
                intent.putExtra("endTime",mEndTime);
                intent.putExtra("endDate",mEndDate);
                startActivity(intent);
                break;
            case R.id.work_main_setting_img:
            case R.id.work_main_setting_layout:
                Intent intent2 = new Intent(getContext(), WorkSettingActivity.class);
                startActivityForResult(intent2,0x0001);
                break;
            default:
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (data != null) {
            mStartDate = data.getStringExtra("startDate");
            mStartTime = data.getStringExtra("startTime");
            mEndDate = data.getStringExtra("endDate");
            mEndTime = data.getStringExtra("endTime");
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
